<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = new Array(2, 34, 6, 98, 45, 876, 32, 21, 907, 453, 4)
            // console.log(arr);
        let min = arr[0]

        for (let i = 0; i < arr.length; i++) {
            if (arr[i] < min) {
                min = arr[i]
            }
        }

        let x = arr[0] - min
        if (arr[0] === min) {
            x = arr[1] - min
        }

        for (let i = 0; i < arr.length; i++) {
            if (arr[i] !== min && arr[i] - min < x) {
                x = arr[i] - min
                min1 = arr[i]
            }
        }
        console.log(min, min1);
    </script>
</body>

</html>